<?php
include 'design.php';
?>
<div class="inhalt">
<?php
	
//Übernahme vom Menü
if (!$link = mysql_connect ('localhost', 'dennis', 'dennis'))
{
	echo "Keine Verbindung zu mysql";
	
}
if (!mysql_select_db('dennis_schuelerdaten', $link))
{
	echo "konnte Datenbank nicht finden";
}

else
{
IF (isset($_GET['Klasse']))
{	

$klasse2 = $_GET['Klasse'];
//Name der Aktivtät
$sortiert="SELECT Vorname, Name, Klasse, Email FROM Schueler WHERE AktivitaetsNr is NULL AND Klasse = '$klasse2'";

mysql_query("SET NAMES 'utf8'");

	//SQL-Befehl senden
	$result4= mysql_query($sortiert,$link);
	

	// Erste Zeile holen
	echo "<table border=3 width=100%>";
		echo "<tr>";
	   echo "<th> Name </th>";
	   echo "<th> Vorname </th>"; 
	   echo "<th> Klasse </th>";
	   echo "</tr>";
	
	
	
	
	$row4= mysql_fetch_assoc($result4);
	while ($row4 != NULL)
	   {
	   

	   echo "<tr><td>";
	   echo "".$row4['Name'];
	   echo "</td>";
	   echo "<td>";
	   echo "".$row4['Vorname'];
	   echo "</td>";
	   echo "<td>";
	   echo "".$row4['Klasse'];
	   echo "</td>";
	   echo "</tr>";
	   
	   
	  // naechste Zeile holen
		$row4= mysql_fetch_assoc($result4);
		
		
	  } 
echo "</table>";	
}
else
{
//Name der Aktivtät
$sql="SELECT Vorname, Name, Klasse, Email FROM Schueler WHERE AktivitaetsNr is NULL";

mysql_query("SET NAMES 'utf8'");

	//SQL-Befehl senden
	$result = mysql_query($sql,$link);
	

	// Erste Zeile holen
	echo "<table border=3 width=100%>";
		echo "<tr>";
	   echo "<th> Name </th>";
	   echo "<th> Vorname </th>"; 
	   echo "<th> Klasse </th>";
	   echo "</tr>";
	
	
	
	
	$row= mysql_fetch_assoc($result);
	while ($row != NULL)
	   {
	   

	   echo "<tr><td>";
	   echo "".$row['Name'];
	   echo "</td>";
	   echo "<td>";
	   echo "".$row['Vorname'];
	   echo "</td>";
	   echo "<td>";
	   echo "".$row['Klasse'];
	   echo "</td>";
	   echo "</tr>";
	   
	   
	  // naechste Zeile holen
		$row= mysql_fetch_assoc($result);
		
		
	  } 
echo "</table>";	  
	  }
	}


?>
</div>
<div class="box">
	 
<?php
$klassen="SELECT DISTINCT Klasse FROM Schueler WHERE AktivitaetsNr IS NULL";
mysql_query("SET NAMES 'utf8'");
	   	
	$result3 = mysql_query($klassen,$link);
	
	// Erste Zeile holen
	$row3= mysql_fetch_assoc($result3);
	
	
	while ($row3 != NULL)
	   {   
	   
	   
	   
	   
	   echo "<a href='teilnehmernicht.php?Klasse=".$row3['Klasse']."'>".$row3['Klasse']."</a>";
	   
	   

	   echo "<br>";
	   
	 
	   // naechste Zeile holen
	   $row3= mysql_fetch_assoc($result3);
		
	  
	  }
	  
	


mysql_close($link);
?>



</div>
</body>
</html>
	
	
	
	
	
	
		
	